package com.tanhua.server.service;

import com.tanhua.dubbo.api.UserLocationApi;
import com.tanhua.server.exception.BusinessException;
import com.tanhua.server.exception.ErrorResult;
import com.tanhua.server.interceptor.UserHolderThreadLocal;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

/**
 * @Description: test
 * @Create by: JJ菜菜
 * @Date: 2021/12/7 18:03
 */
@Service
public class BaiduService {

    @DubboReference
    private UserLocationApi userLocationApi;

    /**
     * 更新地理位置
     * @param longitude 精度
     * @param latitude
     * @param addrStr
     */
    public void location(Double longitude, Double latitude, String addrStr) {

        Long userId = UserHolderThreadLocal.getId();
        Boolean flage = userLocationApi.updateLocation(userId, longitude, latitude, addrStr);
        if(!flage){
            throw new BusinessException(ErrorResult.error());
        }
    }
}
